package com.liuqing.www.web服务;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;

import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.Client;
import org.codehaus.xfire.client.XFireProxy;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
public class XireClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Service srvcModel = new ObjectServiceFactory()
		               .create(IHelloService.class);
		       XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
		               .newInstance().getXFire());
		
		       String helloWorldURL = "http://192.168.1.34:8080/XireWebServer/services/MYHelloService";
		       try {
		            IHelloService srvc = (IHelloService) factory.create(srvcModel,
		                    helloWorldURL);
	           // System.out.println(srvc.sayHello("Robin"));
		            XFireProxy proxy = (XFireProxy)Proxy.getInvocationHandler(srvc);
				    Client client = proxy.getClient();
					    //发送授权信息
					 client.addOutHandler(new ClientAuthenticationHandler("lili","123"));
					 User u=new User();
					    u.setName("RRRRR");
					    Course c=srvc.choose();
					    System.out.println(c.getName());
	            
//		           List  al=new ArrayList();
//		           al.add("1212");
//		            al.add("2222");
//		            List t=srvc.test(al);
//		           for (int i = 0; i < t.size(); i++) {
//		               Course co=(Course)t.get(i);
//		               System.out.println(co.getName());
//		            }
//		            
		           
		        } catch (MalformedURLException e) {
		            e.printStackTrace();
		        }



	}

}
